package com.zx.ishopping.services.impl;

import com.zx.ishopping.entity.Cart;
import com.zx.ishopping.mapper.CartMapper;
import com.zx.ishopping.services.CartService;
import com.zx.ishopping.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CartServiceImpl implements CartService {


    @Autowired
    private CartMapper cartMapper;
    
    /**
     * 获取购物车信息
     * @return
     */
    @Override
    public Cart getCart() {
        //获取当前用户的id
        Long userId = ThreadLocalUtil.get();
        
        Cart cart =  cartMapper.getCartInfo(userId);
        
        return cart;
    }
}
